<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>保证金退回</title>
<jsp:include page="../../import.jsp" flush="true" />
<style type="text/css">
</style>
</head>
<body class="iframeBody">
<div class="Wrapper">
     <div class="fieldset1 tabel_col tabel_col_s clearFix">
        <div class="caption">
			<span class="title">保证金基础信息 </span>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">项目名称</div>
		   <div class="field">
              <span id="fncPrjNm" ></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">项目编号</div>
		   <div class="field">
              <span id="fncPrjId" ></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">融资机构</div>
		   <div class="field">
              <span id="fncInsNm" ></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">已付保证金</div>
		   <div class="field">
              <span id="mrgnAtm" ></span> 
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">付款时间</div>
		   <div class="field">
             <span id="payTm"></span> 
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">剩余保证金</div>
		   <div class="field">
		     <span id="srplsMrgn"></span>
           </div>
		</div>
	 </div>
	 <div class="fieldset1 tabel_col_s clearFix" >
	   <div class="caption">
		   <span class="title" >保证金使用记录</span>
	   </div>
	  <div id="returnDetailligergrid" class="sq-grid"></div>
	</div>
	<div class="fieldset1 tabel_col tabel_col_s clearFix" >
	    <div class="caption">
			<span class="title">保证金退回信息 </span>
		</div>
	   <div class="fieldBox col_33">
		   <div class="label">申请退回保证金</div>
		   <div class="field">
		     <span id="txnAmt"></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">退回时间</div>
		   <div class="field">
		     <span id="txnTm"></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label"></div> 
		   <div class="field">
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">机构付款单位</div>
		   <div class="field">
              <span id="reBanAccNm" ></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">机构付款开户行行名</div>
		   <div class="field">
             <span id="reAccNm"></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">机构付款账号</div>
		   <div class="field">
              <span id="reAccNum" ></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">我司收款单位</div>
		   <div class="field">
             <span id="payBanAccNm"></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">我司收款开户行行名</div>
		   <div class="field">
              <span id="payAccNm" ></span>
           </div>
		</div>
		<div class="fieldBox col_33">
		   <div class="label">我司收款账号</div>
		   <div class="field">
             <span id="payAccNum"></span>
           </div>
		</div>
		
	</div>
	 <!-- hidden -->
	<%-- <input name="prjLgcSn" id="prjLgcSn" type="hidden" class="ui-textbox" value="${prjLgcSn}"  > --%>
	<input name="lgcId" id="lgcId" type="hidden" class="ui-textbox" value="${lgcId}"  > 
</div>
<!-- 嵌入账户详情 -->
<jsp:include page="showAcc.jsp"></jsp:include>
<script type="text/javascript">
   $(function() {
	  initData();
	 });
   
   function initData(){
		  var lgcId='${lgcId}';
		  if(!lgcId)  return;
		  var _url = '<%=path%>/rfbase/mrgnmanageinfo/getMrgnReturnInfoByMgrnLgcId.do';
		   AjaxUtils.ajaxPost(_url, {lgcId:lgcId}, callback);
		}
			
		  //新增回调
	   function callback(msg){
		  if(msg.success == 1){
			  setData(msg.data);//设置数据
		  }else{
			  UIUtils.alertError(msg.info);
		  }
	   }
			
		//设置页面数据
	   function setData(data){
		   var mrgnManageInfo=data.mrgnManageInfo;
		    var mrgnDetailInfoList=mrgnManageInfo.mrgnDetailInfoList;
		    var mrgnReturnInfo=data.mrgnReturnInfo;
		    $("#fncInsNm").html(mrgnManageInfo.fncInsNm);
		    $("#srplsMrgn").html(moneyChange(mrgnManageInfo.srplsMrgn));
			$("#fncPrjNm").html(mrgnManageInfo.fncPrjNm);
			$("#fncPrjId").html(mrgnManageInfo.fncPrjId);
			$("#mrgnAtm").html(moneyChange(mrgnManageInfo.mrgnAtm));
			$("#payTm").html(renderDateChange(mrgnManageInfo.payTm));

			$("#txnAmt").html(moneyChange(mrgnReturnInfo.txnAmt));
			$("#reBanAccNm").html(mrgnReturnInfo.reBanAccNm);
			$("#reAccNm").html(mrgnReturnInfo.reAccNm);
			$("#reAccNum").html("<a href='#' onclick='showInsAcc("+mrgnReturnInfo.recvAcc+")'> <font color='blue'>"+mrgnReturnInfo.reAccNum+"</font></a>");
			
			$("#payBanAccNm").html(mrgnReturnInfo.payBanAccNm);
			$("#payAccNm").html(mrgnReturnInfo.payAccNm);
			$("#payAccNum").html("<a color='blue' href='#' onclick='showSysAcc("+mrgnReturnInfo.payAcc+")'> <font color='blue'>"+mrgnReturnInfo.payAccNum+"</font></a>");
			if(mrgnReturnInfo.txnTm!=null&&mrgnReturnInfo.txnTm!=""){
				$("#txnTm").html(renderDateChange(mrgnReturnInfo.txnTm));
			}
			f_showMrgnReturnListInfo(mrgnDetailInfoList);
			
	  };

	  function f_getDetailData(listChange)
	  {
	      var data = { Rows: [] };
	      for (var i = 0; i < listChange.length; i++)
	      {
	         data.Rows.push(listChange[i]);
	      }
	      return data;
	  }
	  
	  //显示退回记录
	  function f_showMrgnReturnListInfo(mrgnDetailInfoList)
	  { 
		    $("#returnDetailligergrid").ligerGrid({
		        columns: [
		            { display: '申请退回金额',name: "txnAmt", width: 150, render: function (rowdata, rowindex, value, column) { 
		            	var money =moneyChange(value);
	                    return money;
	            		},
	        	      enabledSort:true},    
		            { display: '到账金额', name: 'txnAmt', width: 150, render: function (rowdata, rowindex, value, column) { 
		            	var money =moneyChange(value);
	                    return money;
	            		},
	        	      enabledSort:true},   
		            { display: '到账时间', name: 'txnTm', width: 150 , render:renderDate},
		            { display: '机构收款账号', name: 'reAccNum', width: 150, 
		            	render:function (rowdata, rowindex, value, column) { 
		            	var h ="<a href='#' onclick='showInsAcc("+rowdata.recvAcc+")'> <font color='blue'>"+rowdata.reAccNum+"</font></a>";
	                    return h;
	            		}
		            }, 
		            { display: '机构收款单位', name: 'reBanAccNm', width: 150, render:renderNull},
		            { display: '机构收款开户行行名', name: 'reAccNm', width: 200, render:renderNull},
		            { display: '我司付款账号', name: 'payAccNum', width: 200, 
		            	render:function (rowdata, rowindex, value, column) { 
			            	var h ="<a href='#' onclick='showSysAcc("+rowdata.payAcc+")'> <font color='blue'>"+rowdata.payAccNum+"</font></a>";
		                    return h;
		            		}
		            },
		            { display: '我司付款单位', name: 'payBanAccNm', width: 200, render:renderNull},
		            { display: '我司付款开户行行名', name: 'payAccNm', width: 150, render:renderNull}
		        ],
		        usePager:false,
		        data:f_getDetailData(mrgnDetailInfoList),
		        width:'100%',
		        height:'auto',
		        heightDiff:-2,
		        checkbox:false,
		        rownumbers:true,
		    });
	  }
   
 //格式化时间
 function renderDateChange(value){
	var dateStr = "";
	if(null != value &&  ""!= value){
		var date = new Date(value);
		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
	}
	return dateStr;
 } 
 
//格式化null
 function renderNull(rowdata, index, value){
	var dateStr = "";
	if(null != value){
		var dateStr = value;
	}
	return dateStr;
 }
 
 
 //格式化时间
 function renderDate(rowdata, index, value){
	var dateStr = "";
	if(null != value){
		var date = new Date(value);
		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
	}
	return dateStr;
 }
 
//格式化金额
 function moneyChange(value) { 
		var h = '';
			if(value&&value!="null"){
		    h+=fmoney(value, 2);
			}else{
			h+="0.00";
			}
         return h;
		}
 
 //格式化金额
 function fmoney(s, n)   
	{   
	   n = n > 0 && n <= 20 ? n : 2;   
	   s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";   
	   var l = s.split(".")[0].split("").reverse(),   
	   r = s.split(".")[1];   
	   t = "";   
	   for(i = 0; i < l.length; i ++ )   
	   {   
	      t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");   
	   }   
	   return t.split("").reverse().join("") + "." + r;   
	} 
 
</script>
</body>
</html>
